package com.example.es.springbootes.controller;

import com.example.es.springbootes.dao.HetongDao;
import com.example.es.springbootes.entity.Hetong;
import com.example.es.springbootes.utils.EsHlUtils;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/es/")
public class HetongSearchController {

    @Autowired
    private EsHlUtils esHlUtils;

    @Autowired
    private HetongDao hetongDao;

    @GetMapping("search")
    public PageInfo<Hetong> search(String searchValue) {
        PageInfo search = esHlUtils.search(Hetong.class, 1, 3, "desc", "id", null, searchValue, "mingcheng", "kehu");
        return search;
    }

    /**
     * 新郑保存合同
     * @param hetong
     * @return
     */
    @GetMapping("save")
    public Hetong  save(@RequestBody Hetong hetong) {
        //新增保存合同
        return hetongDao.save(hetong);
    }
}
